	


$(function() {	
	
	realname = document.getElementById('realname').value;
	phone = document.getElementById('phone').value;
	email = document.getElementById('email').value;
	university = document.getElementById('university').value;
	institute = document.getElementById('institute').value;
	grade = document.getElementById('grade').value;
	major = document.getElementById('major').value;
	classes = document.getElementById('classes').value;
	
	setTimeout("getSecurityCode()", 1000);
	
	// 验证真实姓名是否符合规则
	$('input[name="userBean.realname"]').blur(realNameCheck);

	// 验证电话
	$('input[name="userBean.phone"]').blur(phoneCheck);

	// 验证邮箱
	$('input[name="userBean.email"]').blur(emailCheck);

	// 提交按钮
	$('#submit').click(function() {
		if ($('input[name="securityCode"]').val() != securityCode) {
			alert("验证码有误，请重输！");
			refreshSecurityCodeImage();
			getSecurityCode();
			return false;
		} else {
			if (realNameCheck() && phoneCheck() && emailCheck()) {
				$('myform').submit();
			} else {
				alert("注册信息有误，请按照提示信息更改！");
				refreshSecurityCodeImage();
				getSecurityCode();
				return false;
			}
		}
	});

});

function realNameCheck() {

	var str = $('input[name="userBean.realname"]').val();
	if (str != "") {
		var result = str.match(/^[\u4e00-\u9fa5]{2,10}$/);
		if (result == null) {
			$("#realnameCheck").text("真实姓名必须为中文, 长度2-10个中文字符！");
			return false;
		} else {
			$("#realnameCheck").text("");
			return true;
		}
	} else {
		$("#realnameCheck").text("");
		return true;
	}
}

function phoneCheck() {
	var str = $('input[name="userBean.phone"]').val();
	var result = str.match(/^\d{11,13}$/);
	if (result == null) {
		$("#phoneCheck").text("*电话为长度（11-13）的数字！");
		return false;
	} else {
		$("#phoneCheck").text("*");
		return true;
	}
}

function emailCheck() {
	var str = $('input[name="userBean.email"]').val();
	if (str != "") {
		var result = str.match(/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/);
		if (result == null) {
			$("#emailCheck").text("邮箱格式有误！");
			return false;
		} else {
			$("#emailCheck").text("");
			return true;
		}
	} else {
		$("#emailCheck").text("");
		return true;
	}
}
//
//function gotoChange() {
//	if (realname != document.getElementById('realname').value
//			|| phone != document.getElementById('phone').value
//			|| email != document.getElementById('email').value
//			|| university != document.getElementById('university').value
//			|| institute != document.getElementById('institute').value
//			|| grade != document.getElementById('grade').value
//			|| major != document.getElementById('major').value
//			|| classes != document.getElementById('classes').value) 
//	{
//		document.getElementById('submit').disabled = false;
//	} else {
//		document.getElementById('submit').disabled = true;
//	}
//
//}

